W1: Introduction to R

author: Ania Majewska and Reni Kaul date: May 22, 2019 autosize: true font-import: https://fonts.googleapis.com/css?family=PT+Sans font-family: ‘PT Sans’, sans-serif;


Why is R programming a useful skill?

About today’s instructors

Ania Majewska - My research interest is in conservation biology and disease ecology - I use R in my research to: + organize and wrangle data + analyze data (statistical models) + model disease dynamics (transmission) - I mostly work on the monarch butterfly and it’s protozoan parasite - My contact info is majewska@uga.edu

About today’s instructors

Reni Kaul - My research interest is [INSERT DESCRIPTION] - I use R in my research to: + organize data + develop machine learning algorithms + [INSERT DETAILS] - I mostly work [in this disease system or approach] - My contact info is [INSERT EMAIL]

Workshop Goals

left:65% The workshop series consists of four half day workshops each focusing on a different part of the research process - Introduction to R (Today: Ania Majewska and Reni Kaul) - Reproducible research (May 29; Deven Vishwas Gokhale and Reni Kaul ) - Simulating infectious diseases (June 3; John Vinson) - Visualizing data (June 7; Robbie Richards)


workflow

workflow

Workshop Format

Expectations

left:60% You - Come ready to participate + do the reading + review the materials beforehand - Ask questions - Help each other


Instructors - Come prepared - Help you find answers - Be a resource for you during the REU program

Outline

left: 40%

At the end of this workshop you should be able to… - calculate summary statistics of a dataset - create a figure from data

Today

Topics 1. What is R and RStudio? 2. Introduction to R and tidyverse

Break 3. Code along / Exercise

Break 4. Troubleshooting
5. Exploring data in groups

Break 6. Wrap Up 7. Datacamp.com

1. What is R and RStudio?

left: 50%


RStudio

Let’s open Rstudio!

RStudio

RStudio

RStudio

2. Introduction to tidyverse

left: 50%


tidy syntax

tidy syntax

tidyverse package

The tidyverse package is designed to make it easy to install and load core packages from the tidyverse in a single command.

tidy verse package

tidy verse package

Install tidyverse package

# install all the packages in the tidyverse
install.packages("tidyverse") 

Load tidyverse package

# load tidyverse library
library(tidyverse)

========================================================

Download the W1_Exercise zip file

Unzip and open the folder.

Open W1_Exercise.Rproj

========================================================

Break

Resume in 15 min

========================================================

Open W1_Exercise.Rmd

How to get unstuck: functions

left: 35% - Every function has a help page - ?function() to access


manual page

manual page

How to get unstuck: packages

left: 50% * Packages have a vignette and/or reference manual on cran.r-project.org

How to get unstuck: packages

left: 30%


cheatsheets

cheatsheets

https://www.rstudio.com/resources/cheatsheets/

How to get unstuck: packages

left: 30%


cheatsheets

cheatsheets

How to get unstuck: error messages

error

error

First, try to understand the error message. It can be very helpful.

How to get unstuck: error messages

left: 30%


google

google

Exploring further

Let’s work in small groups (max of 3)

More instructions in the file.

Wrap Up

left: 50%

We can… - calculate summary statistics of a dataset - create a figure from data

using - dplyr package - filter, arrange… - ggplot2 package - geom_point, facet…


W1

W1

Wrap Up

left: 50%

Next week

Focus on communication by following best practices for reproducible research


W1

W1

Datacamp.com

We will be using datacamp.com to build more skills!